<#assign module="marketing"/>

<@override name="header">
</@override>
<@override name="body">
<div class="tabbable tabs-left">
	<div class="row">
		
		<div class="col-xs-12 col-md-12">
			<button class="pull-right btn btn-primary" onclick="window.location='${ctx}/couponrule/mass/${couponRule.id}';"><i class="icon-plus"></i>&nbsp;生成优惠劵</button>
	 		<button class="pull-right btn btn-primary btn-primary-a" onclick="window.location='${ctx}/couponrule/export/${couponRule.id}';"><i class="glyphicon glyphicon-save"></i>&nbsp;导出优惠劵</button>
		</div>
		<div class="col-xs-1">
		</div>
	</div>
</div>

<div class="tab-content" >
	<div class="container-fluid ">
  		<div class="row ">
			<div class="col-xs-11" style="padding: 0px; ">
				<form class="form-inline" id="SearchForm" method="get">
					<input  id="couponRuleId" name="couponRuleId"  type="hidden" value="${couponRule.id}">
					<div class="form-group">
						<input class="form-control" id="couponCode" name="couponCode" placeholder="输入优惠券编码" type="text" value="">
					</div>
					<div class="form-group">
				    	<input class="form-control" id="phone" name="phone" placeholder="输入客户电话" type="text" value="">
				    </div>
				    <div class="form-group">
				    	<input type="button" id="searchButton" class="btn btn-default" value="查询">
				    </div>
			    	<div class="form-group">
				    	<input type="button" id="clear_time" class="btn btn-default" value="全部">
				    </div>
		       	</form>
			</div>	
		</div>	
	</div>	
</div>	

<!--列表-->
<div class="tabta-content" style="margin-top:10px;">  	
	<table class="table table-condensed table-striped">
	
	<div class="panel panel-default">
		<div class="panel-heading">
		
			${couponRule.title}&nbsp;&nbsp;
			有效期：${couponRule.start?string('yyyy/MM/dd')}&nbsp;-&nbsp;
			<#if couponRule.end??>
			${couponRule.end?string('yyyy/MM/dd')}
			<#else>
				不限
			</#if>
			&nbsp;&nbsp;
			<#if couponRule.timeStatus==0>
				（未开始）
			<#elseif couponRule.timeStatus==1>
				（使用中）
			<#elseif couponRule.timeStatus==2>
				（已过期）
			</#if>
	    </div>
    </div>
		<tbody>
			<tr>
				<th>编码</th>
				<th>密码</th>
				<th>使用状态</th>
				<th>客户称呼/手机号</th>
				<th>客户类型</th>
				<th>生成时间</th>
<#--				<th>线路</th>-->
<#--				<th>金额</th>-->
				<th>操作</th>
			</tr>
		</tbody>
	</table>
		<br><div style="text-align:center" id="NoData"></div></br>
		<ul class="pagination pull-left pagination-sm pageshow" id="pageshow" style="display:none;">
			<li><a></a></li>
		</ul>
		<ul class="pagination pull-left pagination-sm pagedata" id="pagedata" style="display:none;">
	    </ul>
</div>


</@override>
<@override name="footer">
<script type="text/javascript">
	var main=false;
	<@shiro.isMainCompany>
		main=true;
	</@shiro.isMainCompany>
</script>
<script type="text/javascript">

	var thisButton;
	
	function invalidCoupon() {
	    $.post('${ctx}/couponrule/invalidCouponData',{'id':thisButton.attr("data-value")},function(data){
            if(data.success){
                $.scojs_message('操作成功', $.scojs_message.TYPE_OK);
                window.location.reload(true);//强制刷新
            } else {
                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
            }
	    },'json');
	}
	
	$(document).ready(function(){
		$(document).on("click",".invalidthis",function(){
	          thisButton = $(this);
	          var confirm = $.scojs_confirm({
            	content: "确认要让该优惠劵失效吗？",
	            action:invalidCoupon
	          });
	          confirm.show();
	    });
	});
	
</script>
<script src="${ctx}/assets/js/jquery.paging.min.js"></script>
<script src="${ctx}/assets/js/couponrule/couponlist.js"></script>
</@override>
<@extends name="../layout.ftl"/>